//696. 计数二进制子串


/**
 * @param {string} s
 * @return {number}
 */
var countBinarySubstrings = function(s) {
    if(s.length===0) return 0
    let ans = 0
    let first =0
    let second =1
    let char = s.charAt(0)
    for (let i=1;i<s.length;i++) {
        if(char===s.charAt(i)){
            second++
        }else{
            //计算
            let min = Math.min(first,second)
            ans +=min
            first = second
            second=1
            char=s.charAt(i)
        }
    }
    let min = Math.min(first,second)
    ans +=min
    return ans
};


let ans = countBinarySubstrings("10101")
console.log(ans)